package com.he.ymw.service.impl;

import com.he.ymw.dao.BuyCarDao;
import com.he.ymw.pojo.BuyCar;
import com.he.ymw.pojo.BuyCarVo;
import com.he.ymw.service.BuyCarService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BuyCarServiceImpl implements BuyCarService {

    @Resource
    BuyCarDao buyCarDao;

    @Override
    public List<BuyCarVo> findBuyCarAll(Integer userID) {
        return buyCarDao.findBuyCarAll(userID);
    }

    /**
     * 加入购物车
     */
    @Override
    public int addBuyCar(BuyCar buyCar) {
        return buyCarDao.addBuyCar(buyCar);
    }

    /**
     * 更新商品数量
     * @param id 商品id
     * @param cost 总价格
     * @param quantity 数量
     * @return
     */
    @Override
    public boolean addGoodsQuantity(Integer id, Integer cost, Integer quantity) {
        return buyCarDao.addGoodsQuantity(id,cost,quantity);
    }

    /**
     * 查询商品价格
     * @param id 商品id
     * @return
     */
    @Override
    public Integer findPrice(Integer id) {
        return buyCarDao.findPrice(id);
    }

}
